<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('signature_selection'))
{
	function signature_selection($article)
	{
        /* @var $article OxArticle */
        $v = '';
        if($article->idarticle)
        {
            $v = $article->signature_style;
            if($article->signature_style > 3)
            {
                $v .= $article->organization->idorganization;
            }
        }
		$s = '<select id="signature_type_selection" onchange="signature_type_changed()" style="width:67%">
<option value="1"'.($v=='1'?' selected="selected"':'').'>Full name ('.$article->user->name.')</option>
<option value="2"'.($v=='2'?' selected="selected"':'').'>Username only (' .$article->user->username.')</option>
<option value="3"'.($v=='3'?' selected="selected"':'').'>Custom signature (write your own text)</option>';
        /* @var $user OxUser */
        $user = $article->user;
        
        foreach($user->roles() as $role)
        {
            /* @var $org OxOrganization */
            $org = $role->organization;
            $s .= '<option value="4'.$role->idorganization.'"'.($v=='4'.$role->idorganization?' selected="selected"':'').'>Organization name ('.$org->name.')</option>';
            $s .= '<option value="5'.$role->idorganization.'"'.($v=='5'.$role->idorganization?' selected="selected"':'').'>Name, title and organization ('.$article->user->name.
                    ', '.$role->role.' of '.$org->name.')</option>';
        }
        
        $s .= '<option value="0">Anonymous (no link to profile)</option></select>';
        
        return $s;
	}
}
